package cn.nfwx.tv.db;

import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.Ignore;
import android.arch.persistence.room.PrimaryKey;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.IntRange;

import cn.nfwx.tv.down.DownloadStatus;

/**
 * Created by zhouzechao on 2018/7/8.
 */


@Entity(tableName = "tb_program")
public class DownProgramModel implements Parcelable {

    public DownProgramModel(String programName, String programTime, String downloadUrl, String basePath, String localPath, String imagePath, int stats, int size) {
        super();
        this.programName = programName;
        this.programTime = programTime;
        this.downloadUrl = downloadUrl;
        this.basePath = basePath;
        this.localPath = localPath;
        this.imagePath = imagePath;
        this.stats = stats;
        this.size = size;
    }

    @Ignore
    public DownProgramModel() {
        super();
    }

    public final static int STATS_DEFAULT = 0;
    public final static int STATS_DOWNLOADING = 1;
    public final static int STATS_DOWNLOADED = 6;
    public final static int STATS_PAUSE = 2;
    public final static int STATS_SUCCESS = 3;
    public final static int STATS_WAIT = 4;
    public final static int STATS_FAIL = 5;

    @PrimaryKey(autoGenerate = true)
    private int id;

    @ColumnInfo(name = "programName")
    private String programName;

    @ColumnInfo(name = "programTime")
    private String programTime;

    @ColumnInfo(name = "downloadUrl")
    private String downloadUrl;

    @ColumnInfo(name = "basePath")
    private String basePath;

    @ColumnInfo(name = "localPath")
    private String localPath;

    @ColumnInfo(name = "stats")
    private int stats;

    @ColumnInfo(name = "size")
    private int size;

    @ColumnInfo(name = "downloadLocation")
    private int downloadLocation;

    @ColumnInfo(name = "downloadLocationTs")
    private String downloadLocationTs;

    @ColumnInfo(name = "imagePath")
    private String imagePath;

    @IntRange(from = DownloadStatus.WAIT, to = DownloadStatus.FAIL)
    @Ignore
    private int downloadStatus = DownloadStatus.PAUSE;   //下载的状态信息

    @Ignore
    private boolean isCheck;

    @Ignore
    public DownProgramModel(Parcel in) {
        super();
        id = in.readInt();
        programName = in.readString();
        programTime = in.readString();
        downloadUrl = in.readString();
        basePath = in.readString();
        localPath = in.readString();
        stats = in.readInt();
        size = in.readInt();
        downloadLocation = in.readInt();
        downloadLocationTs = in.readString();
        imagePath = in.readString();
        downloadStatus = in.readInt();
    }

    public static final Creator<DownProgramModel> CREATOR = new Creator<DownProgramModel>() {
        @Override
        public DownProgramModel createFromParcel(Parcel in) {
            return new DownProgramModel(in);
        }

        @Override
        public DownProgramModel[] newArray(int size) {
            return new DownProgramModel[size];
        }
    };

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getProgramName() {
        return programName;
    }

    public void setProgramName(String programName) {
        this.programName = programName;
    }

    public String getProgramTime() {
        return programTime;
    }

    public void setProgramTime(String programTime) {
        this.programTime = programTime;
    }

    public String getDownloadUrl() {
        return downloadUrl;
    }

    public void setDownloadUrl(String downloadUrl) {
        this.downloadUrl = downloadUrl;
    }

    public String getLocalPath() {
        return localPath;
    }

    public void setLocalPath(String localPath) {
        this.localPath = localPath;
    }

    public int getStats() {
        return stats;
    }

    public void setStats(int stats) {
        this.stats = stats;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public String getBasePath() {
        return basePath;
    }

    public void setBasePath(String basePath) {
        this.basePath = basePath;
    }

    public int getDownloadLocation() {
        return downloadLocation;
    }

    public void setDownloadLocation(int downloadLocation) {
        this.downloadLocation = downloadLocation;
    }

    public String getDownloadLocationTs() {
        return downloadLocationTs;
    }

    public void setDownloadLocationTs(String downloadLocationTs) {
        this.downloadLocationTs = downloadLocationTs;
    }

    public int getDownloadStatus() {
        return downloadStatus;
    }

    public void setDownloadStatus(int downloadStatus) {
        this.downloadStatus = downloadStatus;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(programName);
        dest.writeString(programTime);
        dest.writeString(downloadUrl);
        dest.writeString(basePath);
        dest.writeString(localPath);
        dest.writeInt(stats);
        dest.writeInt(size);
        dest.writeInt(downloadLocation);
        dest.writeString(downloadLocationTs);
        dest.writeString(imagePath);
        dest.writeInt(downloadStatus);
    }

    public boolean isCheck() {
        return isCheck;
    }

    public void setCheck(boolean isCheck) {
        this.isCheck = isCheck;
    }

    public String getImagePath() {
        return imagePath;
    }

    public void setImagePath(String imagePath) {
        this.imagePath = imagePath;
    }
}